﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Byte : Ship
{
    public ParticleSystem m_Rage;
    public AudioSource m_RageAudio;
    bool m_IsOpen = false;

    float m_DurationTimeCount = 0;
    float m_DurationTimeMax = 6.5f;

    float m_SpurtTimeCount = 0;
    float m_SpurtTimeMax = 0.06f;
    protected new void Start()
    {
        base.Start();
    }

    // Update is called once per frame
    protected new void Update()
    {
        base.Update();
        if (!m_IsOpen)
            return;

        if (m_IsOpen)
        {
            m_DurationTimeCount += Time.deltaTime;
            if (m_DurationTimeCount > m_DurationTimeMax)
            {
                m_DurationTimeCount = 0;
                m_IsOpen = false;
                var main = m_Rage.main;
                main.loop = false;
                VelocityMutiple = 1;
                ShotVelocityMutiple = 1f;
            }
        }
        if (m_SpurtTimeCount < m_SpurtTimeMax)
            VelocityMutiple = 30;
        else
            VelocityMutiple = 1;
        m_SpurtTimeCount += Time.deltaTime;
    }

    public override bool LaunchSkill()
    {
        if (!base.LaunchSkill())
            return false;

        ShotVelocityMutiple = 1.65f;
        var main = m_Rage.main;
        main.loop = true;
        m_Rage.Play();
        m_IsOpen = true;
        m_SpurtTimeCount = 0;
        m_RageAudio.Play();
        return true;
    }
    public override void OnChase()
    {
        if(SkillIsReady)
            LaunchSkill();
    }
    public override void OnFight()
    {
    }
    public override void OnRetreat()
    {
        if (SkillIsReady)
            LaunchSkill();
    }
}
